<?php
$params = array_merge(
    require __DIR__ . '/../../common/config/params.php',
    require __DIR__ . '/../../common/config/params-local.php',
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    'id' => 'app-api',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'api\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-api',
        ],
        'user' => [
            'identityClass' => 'api\models\User',
            'enableAutoLogin' => true,
            'enableSession'=>false,
//            'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the api
            'name' => 'advanced-api',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'base/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,//是否开启美化
            'enableStrictParsing' => true,//启动url严格匹配模式
            'showScriptName' => false,//是否在api中显示index.php
            'rules' => [
                'index' => 'test/index',
                'create' => 'test/add',
                'delete' => 'test/del',
                'modify' => 'test/modify',
                'find' => 'test/find',
                'register' => 'user/register',
                'userinfo' => 'user/user-info',
                'releaseContent' => 'content/release-content',
                'addCate' => 'cate/add-cate',
                [
                    'pattern' => 'findContent',
                    'route' => 'content/find',
                    'defaults' => [
                        'expand' => 'cate'
                    ]
                ]
            ],
        ],
    ],
    'params' => $params,
];
